package com.jiangruan.javaproject.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jiangruan.javaproject.Constans;
import com.jiangruan.javaproject.bean.NBAGame;
import com.jiangruan.javaproject.bean.NBAGemaCommon;
import com.jiangruan.javaproject.request.HttpUtils;

import java.util.List;

/**
 * @author:SAVA ME(未蒙救赎)
 * @email:1902586238@qq.com
 * @desc:
 * @datetime:2021/12/24 20:38
 **/
public class NBAGameService {
    public List<NBAGame> getNBAGame() {
        /**
         * 该方法用于获取NBA赛事，并将赛事数据返回
         * @retun
         */
        String url = Constans.NBA_URL +
                "?key=" + Constans.NBA_KEY;

        String result = HttpUtils.git(url);
        System.out.println(result);


        //json解析
       NBAGemaCommon nbaGemaCommon = JSONArray.parseObject(result, NBAGemaCommon.class);
       return nbaGemaCommon.result;
    }
}

